#include "dialog.h"

#include <qfiledialog.h>

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::DialogClass())
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_pushButton_openFile_clicked()
{
    QString currentDir = QCoreApplication::applicationDirPath();//当前应用目录
    QString aFile = QFileDialog::getOpenFileName(this, "打开一个文件", currentDir, "所有文件(*.*)");//此函数返回的是路径和文件名
    
    ui->lineEdit_File->setText(aFile);
}

void Dialog::on_pushButton_openDirectory_clicked()
{
    QString currentDir = QCoreApplication::applicationDirPath();//当前应用目录
    QString aDir = QFileDialog::getExistingDirectory(this, "选择一个目录", currentDir);
    ui->lineEdit_Directory->setText(aDir);
}

void Dialog::on_pushButton_clicked()
{
    QString currentDir = QCoreApplication::applicationDirPath();//当前应用目录
    ui->plainTextEdit_Information->appendPlainText("当前应用目录:" + currentDir);

}

void Dialog::on_pushButton_2_clicked()
{
    QString currentFilePath = QCoreApplication::applicationFilePath();//当前应用文件路径
    ui->plainTextEdit_Information->appendPlainText("当前应用文件路径:" + currentFilePath);
}

void Dialog::on_pushButton_3_clicked()
{
    QString str = QCoreApplication::applicationName();//当前应用程序名称
    ui->plainTextEdit_Information->appendPlainText("当前应用程序名称:" + str);

    //QCoreApplication::setApplicationName("MyApp");//设置应用程序名称（不改变文件名，不知道有什么用）
}

void Dialog::on_pushButton_6_clicked()
{
    QCoreApplication::setApplicationName("MyApp");//设置应用程序名称（不改变文件名，不知道有什么用）
    ui->plainTextEdit_Information->appendPlainText("设置应用程序名称为:Myapp");
}

void Dialog::on_pushButton_5_clicked()
{
    QStringList strList = QCoreApplication::libraryPaths();
    ui->plainTextEdit_Information->appendPlainText("用到的库：");
    for (auto& item : strList)
    {
        ui->plainTextEdit_Information->appendPlainText(item);
    }
}

void Dialog::on_pushButton_4_clicked()
{
    QCoreApplication::setOrganizationName("An_Organization");
    ui->plainTextEdit_Information->appendPlainText("设置公司名称为：An_Organization");

    QString str = QCoreApplication::organizationName();
    ui->plainTextEdit_Information->appendPlainText("公司名称:" + str);
}

void Dialog::on_pushButton_ApplicationExit_clicked()
{
    QCoreApplication::exit();
}


